WOLF core
WOLF: A Modular Estimation Framework for Robotics
XXXXXXXXXXXXXXXXXXXXXXXXvoid(0)" frameborder="0" name="MSearchResults" id="MSearchResults">
utils_gtest.h File Reference
#include <gtest/gtest.h>
#include <Eigen/Dense>

Go to the source code of this file.

Namespaces

namespace  testing
 

Macros

#define EXPECT_MATRIX_APPROX(C_expect, C_actual, precision)
 
#define ASSERT_MATRIX_APPROX(C_expect, C_actual, precision)
 
#define EXPECT_QUATERNION_APPROX(C_expect, C_actual, precision)
 
#define ASSERT_QUATERNION_APPROX(C_expect, C_actual, precision)
 
#define EXPECT_QUATERNION_VECTOR_APPROX(C_expect, C_actual, precision)
 
#define ASSERT_QUATERNION_VECTOR_APPROX(C_expect, C_actual, precision)
 
#define EXPECT_POSE2d_APPROX(C_expect, C_actual, precision)
 
#define ASSERT_POSE2d_APPROX(C_expect, C_actual, precision)
 
#define EXPECT_POSE3d_APPROX(C_expect, C_actual, precision)
 
#define ASSERT_POSE3d_APPROX(C_expect, C_actual, precision)
 

Functions

bool is_running_under_ctest ()
 Checks if the code is running under CTest Useful to avoid launching visualizers and other interactive elements that would block the tests. More...
 

Macro Definition Documentation

◆ ASSERT_MATRIX_APPROX

#define ASSERT_MATRIX_APPROX (   C_expect,
  C_actual,
  precision 
)
Value:
ASSERT_PRED2([](const Eigen::MatrixXd& lhs, \
const Eigen::MatrixXd& rhs) { return (lhs - rhs).isMuchSmallerThan(1, precision); }, \
C_expect, \
C_actual);

◆ ASSERT_POSE2d_APPROX

#define ASSERT_POSE2d_APPROX (   C_expect,
  C_actual,
  precision 
)
Value:
ASSERT_PRED2( \
[](const Eigen::VectorXd& lhs, const Eigen::VectorXd& rhs) { \
assert(lhs.size() == 3 and rhs.size() == 3); \
Eigen::VectorXd er = lhs - rhs; \
er(2) = remainder((double)er(2), 2 * M_PI); \
return er.isMuchSmallerThan(1, precision); \
}, \
C_expect, \
C_actual);
Jet< double, N > remainder(const Jet< double, N > &_x, long double _y)
Definition: wolf_jet.h:31

◆ ASSERT_POSE3d_APPROX

#define ASSERT_POSE3d_APPROX (   C_expect,
  C_actual,
  precision 
)
Value:
ASSERT_PRED2( \
[](const Eigen::VectorXd& lhs, const Eigen::VectorXd& rhs) { \
assert(lhs.size() == 7 and rhs.size() == 7); \
Eigen::Vector4d er; \
er.head(3) = lhs.head(3) - rhs.head(3); \
er(3) = Eigen::Quaterniond(Eigen::Vector4d(lhs.tail(4))) \
.angularDistance(Eigen::Quaterniond(Eigen::Vector4d(rhs.tail(4)))); \
return er.isMuchSmallerThan(1, precision); \
}, \
C_expect, \
C_actual);

◆ ASSERT_QUATERNION_APPROX

#define ASSERT_QUATERNION_APPROX (   C_expect,
  C_actual,
  precision 
)
Value:
ASSERT_PRED2([](const Eigen::Quaterniond& lhs, \
const Eigen::Quaterniond& rhs) { return lhs.angularDistance(rhs) < precision; }, \
C_expect, \
C_actual);

◆ ASSERT_QUATERNION_VECTOR_APPROX

#define ASSERT_QUATERNION_VECTOR_APPROX (   C_expect,
  C_actual,
  precision 
)
Value:
ASSERT_PRED2( \
[](const Eigen::VectorXd& lhs, const Eigen::VectorXd& rhs) { \
return Eigen::Quaterniond(Eigen::Vector4d(lhs)) \
.angularDistance(Eigen::Quaterniond(Eigen::Vector4d(rhs))) < precision; \
}, \
C_expect, \
C_actual);

◆ EXPECT_MATRIX_APPROX

#define EXPECT_MATRIX_APPROX (   C_expect,
  C_actual,
  precision 
)
Value:
EXPECT_PRED2([](const Eigen::MatrixXd& lhs, \
const Eigen::MatrixXd& rhs) { return (lhs - rhs).isMuchSmallerThan(1, precision); }, \
C_expect, \
C_actual);

◆ EXPECT_POSE2d_APPROX

#define EXPECT_POSE2d_APPROX (   C_expect,
  C_actual,
  precision 
)
Value:
EXPECT_PRED2( \
[](const Eigen::VectorXd& lhs, const Eigen::VectorXd& rhs) { \
assert(lhs.size() == 3 and rhs.size() == 3); \
Eigen::VectorXd er = lhs - rhs; \
er(2) = remainder((double)er(2), 2 * M_PI); \
return er.isMuchSmallerThan(1, precision); \
}, \
C_expect, \
C_actual);

◆ EXPECT_POSE3d_APPROX

#define EXPECT_POSE3d_APPROX (   C_expect,
  C_actual,
  precision 
)
Value:
EXPECT_PRED2( \
[](const Eigen::VectorXd& lhs, const Eigen::VectorXd& rhs) { \
assert(lhs.size() == 7 and rhs.size() == 7); \
Eigen::Vector4d er; \
er.head(3) = lhs.head(3) - rhs.head(3); \
er(3) = Eigen::Quaterniond(Eigen::Vector4d(lhs.tail(4))) \
.angularDistance(Eigen::Quaterniond(Eigen::Vector4d(rhs.tail(4)))); \
return er.isMuchSmallerThan(1, precision); \
}, \
C_expect, \
C_actual);

◆ EXPECT_QUATERNION_APPROX

#define EXPECT_QUATERNION_APPROX (   C_expect,
  C_actual,
  precision 
)
Value:
EXPECT_PRED2([](const Eigen::Quaterniond& lhs, \
const Eigen::Quaterniond& rhs) { return lhs.angularDistance(rhs) < precision; }, \
C_expect, \
C_actual);

◆ EXPECT_QUATERNION_VECTOR_APPROX

#define EXPECT_QUATERNION_VECTOR_APPROX (   C_expect,
  C_actual,
  precision 
)
Value:
EXPECT_PRED2( \
[](const Eigen::VectorXd& lhs, const Eigen::VectorXd& rhs) { \
return Eigen::Quaterniond(Eigen::Vector4d(lhs)) \
.angularDistance(Eigen::Quaterniond(Eigen::Vector4d(rhs))) < precision; \
}, \
C_expect, \
C_actual);

Function Documentation

◆ is_running_under_ctest()

bool is_running_under_ctest ( )

Checks if the code is running under CTest Useful to avoid launching visualizers and other interactive elements that would block the tests.

Returns
true if running under CTest, false otherwise.